﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ExcelTransfer : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string strContent = Request["content"];

        if (string.IsNullOrEmpty(strContent))
            return;

        string strFileName = Request["fileName"];

        if (string.IsNullOrEmpty(strFileName))
        {
            strFileName = "表格";
        }

        Response.Clear();
        Response.Buffer = true;

        Response.Charset = System.Text.Encoding.UTF8.WebName;
        Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(strFileName) + ".xls");
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        Response.ContentType = "application/ms-excel";
        this.EnableViewState = false;
        Response.Write("<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" /></head><body>" + strContent + "</body></html>");
        //Response.Write(strContent);
        Response.End();

    }
}
